import axios from 'axios';

export default {
  getLanguage : (url)=>{
    var language = localStorage.getItem('language') || 'en-us'
    return axios.get('/language/'+language+'/'+url)
  },
  getMoney:(money=0)=>{
    return parseInt(money).toLocaleString();
  },
  getGain:(record)=>{
    let number = (record.lastprice-record.costprice)/record.costprice;
    let percent = Number(number*100).toFixed(2)
    percent+="%";

    (record.lastprice - record.lastclose)/record.lastclose
    return percent;
  },
  getNowGain:(record)=>{
    let percent = 0;
    if(record.lastclose>0){
      let number = (record.lastprice-record.lastclose)/record.lastclose;
      percent = Number(number*100).toFixed(2)
    }
    
    percent+="%";

    
    return percent;
  },
  getSharesInfoUrl:(record)=>{
    let arr = record.stcode.split(".")
    return "http://finance.sina.com.cn/realstock/company/"+arr[1].toLowerCase()+arr[0]+"/nc.shtml";
  }
}